package com.fintech.third.service.bairong;

import java.net.URLEncoder;
import java.util.Date;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.fintech.common.enums.RespStatus;
import com.fintech.common.service.BaseServiceImpl;
import com.fintech.common.util.ApiResponse;
import com.fintech.common.util.PropertiesUtils;
import com.fintech.datagroud.service.DGBaiRongService;
import com.fintech.third.constant.LocalStatus;
import com.fintech.third.constant.ThirdMethodConstants;
import com.fintech.third.dao.interfacedata.EdcDataCallOperationRecordsMapper;
import com.fintech.third.dao.interfacedata.EdcProductInterfaceEffecttimeConfigMapper;
import com.fintech.third.model.ThirdProperties;
import com.fintech.third.model.bairong.ApplicationInfoAssociate;
import com.fintech.third.model.bairong.MultipleApplications;
import com.fintech.third.model.bairong.Score;
import com.fintech.third.model.bairong.WhetherTheUserIsWhiteList;
import com.fintech.third.model.bairong.XssPackAllInterfaceInfo;
import com.fintech.third.utils.SerialNumCreater;
import com.fintech.third.utils.ThirdPropertiesInitUtil;
import com.fintech.third.utils.bairong.BaiRongUtil;
import com.marvels.common.utils.MarvelsLogUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Service("baiRongWhiteListInterface")
public class BaiRongWhiteListImpl extends BaseServiceImpl implements BaiRongWhiteListInterface {

	@Autowired
	private DGBaiRongService dGBaiRongService;

	@Autowired
	private EdcProductInterfaceEffecttimeConfigMapper edcProductInterfaceEffecttimeConfigMapper;

	@Autowired
	private EdcDataCallOperationRecordsMapper edcDataCallOperationRecordsMapper;

//	@Autowired
//	private loanInfoIDragonService loanInfoIDragonService;
//
//	@Autowired
//	private DecisionWhiteListService decisionWhiteListService;
//	@Autowired
//	private acLoanApplyInfoExtDragonService acLoanApplyInfoExtDragonService;

	/**
	 * 登陆百融方法
	 * 
	 * @return tokenId 任务Id
	 */
	public String platLogin(String userName, String password, String apiCode, String requestUrl) {
		JSONObject json = new JSONObject();
		json.put("userName", userName);
		json.put("password", password);
		json.put("apiCode", apiCode);
		String result = "";
		String tokenId = "";
		try {
			result = BaiRongUtil.urlConnectPost(requestUrl,
					"userName=" + userName + "&password=" + password + "&apiCode=" + apiCode);
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>百融白名单登录异常:" + e);
		}

		if (StringUtils.isNotEmpty(result)) {
			MarvelsLogUtil.getInstance().info("平台登录百融返回信息:" + result);
			JSONObject resultJson = new JSONObject();
			resultJson = JSONObject.fromObject(result);
			if (resultJson.get("code").toString().equals("00")) {
				tokenId = resultJson.get("tokenid").toString();
			}
		}
		return tokenId;
	}

	public ApiResponse whetherTheUserIsWhiteListDeal(Map<String, String> map) {
		ApiResponse<WhetherTheUserIsWhiteList> resp = new ApiResponse<WhetherTheUserIsWhiteList>();
//		/*
//		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
//		 */
//		if (PropertiesUtils.isTurnOffForSwitch("switch.br0054")) {
//			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
//			resp.setCode(RespStatus.DISABLE.getCode());
//			resp.setMsg(RespStatus.DISABLE.getMsg());
//			return resp;
//		}
//		String loanId = map.get("loanId");
//		String channel = map.get("channel");
//		String serialNum = System.currentTimeMillis() + "_" + RandomStringUtils.randomAlphanumeric(6);
//		WhetherTheUserIsWhiteList whetherTheUserIsWhiteList = new WhetherTheUserIsWhiteList();
//		whetherTheUserIsWhiteList.setWhiteList(false);
//
//		JSONObject multipleJson = new JSONObject();
//		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
//		Date sTime = new Date();
//
//		String companyNum = thirdProperties.getBr_whiteList_company_num();
//		multipleJson.put("meal", "WhiteList_v");
//		multipleJson.put("id", BaiRongUtil.genMd5(map.get("idNumber")));
//		multipleJson.put("cell", BaiRongUtil.genMd5(map.get("mobile")));
//		multipleJson.put("name", map.get("name"));
//		multipleJson.put("channel_num", map.get("channelNum"));
//		multipleJson.put("company_num", companyNum);
//		MarvelsLogUtil.getInstance().info(">>>>>>>>>>>>>loanId:" + loanId + ",百融判断用户白名单接口请求参数:" + multipleJson.toString());
//		String brWhiteListMerchantName = thirdProperties.getBr_whiteList_merchantName();
//		String brWhiteListMerchantPwd = thirdProperties.getBr_whiteList_merchantPwd();
//		String brWhiteListApiCode = thirdProperties.getBr_whiteList_apiCode();
//		String brWhiteListLoginUrl = thirdProperties.getBr_loginRequestUrl();
//		String brWhiteListquestReUrl = thirdProperties.getBr_whiteList_request_url();
//		String tokenId = platLogin(brWhiteListMerchantName, brWhiteListMerchantPwd, brWhiteListApiCode,
//				brWhiteListLoginUrl);
//		String result = "";
//		String swift_number = "";
//		String code = "";
//		Date responseDate = null;
//		String localStatus = LocalStatus.REQUEST_FAIL.getCode();
//		String method = ThirdMethodConstants.BR0054;
//		if (StringUtils.isEmpty(tokenId)) {
//			resp.setCode(RespStatus.REQ_ERROR.getCode());
//			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
//		} else {
//			try {
//				result = BaiRongUtil.urlConnectPost(brWhiteListquestReUrl,
//						"tokenid=" + tokenId + "&apiCode=" + brWhiteListApiCode + "&jsonData="
//								+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
//								+ BaiRongUtil.getCheckData(multipleJson.toString(), brWhiteListApiCode, tokenId));
//
//			} catch (Exception e) {
//				MarvelsLogUtil.getInstance().error(">>>>>>>>>loanId:" + loanId + "百融判断用户白名单接口请求异常", e);
//				resp.setCode(RespStatus.REQ_ERROR.getCode());
//				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
//			}
//			responseDate = new Date();
//			if (StringUtils.isNotEmpty(result)) {
//				MarvelsLogUtil.getInstance().info(">>>>>>>>>loanId:" + loanId + ",百融判断用户白名单接口返回信息:" + result);
//				code = JSONObject.fromObject(result).getString("code");
//				if (code.equals("600000")) {
//					localStatus = LocalStatus.SUCCESS_WITH_DATA.getCode();
//					try {
//						whetherTheUserIsWhiteList = JSON.parseObject(result, WhetherTheUserIsWhiteList.class);
//						resp.setCode(RespStatus.SUCCESS.getCode());
//						resp.setMsg(RespStatus.SUCCESS.getMsg());
//						String status = whetherTheUserIsWhiteList.getProduct().getStatus();// 00：命中白名单
//																							// 01：未命中白名单
//																							// 02：缺少输入参数
//						if ("00".equals(status)) {
//							whetherTheUserIsWhiteList.setWhiteList(true);
//							// 落库
//							DecisionWhiteListBatch decisionWhiteListBatch = new DecisionWhiteListBatch();
//							decisionWhiteListBatch.setBatchType("2");
//							decisionWhiteListBatch.setCreatedBy("sys");
//							decisionWhiteListBatch.setFetchType("br0054");
//							decisionWhiteListBatch.setCreatedDate(new Date());
//							decisionWhiteListBatch.setEventName("百融白名单");
//							decisionWhiteListBatch.setEventCode(ThirdMethodConstants.BR0054);
//							Map<String, Object> returnMap = decisionWhiteListService
//									.insertDecisionWhiteListBatch(decisionWhiteListBatch, "Br");
//							if ((int) (returnMap.get("count")) > 0) {
//								DecisionWhiteListInfo decisionWhiteListInfo = new DecisionWhiteListInfo();
//								decisionWhiteListInfo.setBatchNo(returnMap.get("batchNo").toString());
//								decisionWhiteListInfo.setCustName(map.get("name"));
//								decisionWhiteListInfo.setIdCard(map.get("idNumber"));
//								decisionWhiteListInfo.setMobileNo(map.get("mobile"));
//								decisionWhiteListInfo.setSource("百融");
//								decisionWhiteListInfo.setCreatedBy("sys");
//								decisionWhiteListInfo.setCreatedDate(new Date());
//								decisionWhiteListInfo.setUpdatedBy("sys");
//								decisionWhiteListInfo.setUpdatedDate(new Date());
//								decisionWhiteListService.insertDecisionWhiteListInfo(decisionWhiteListInfo);
//							}
//						}
//					} catch (Exception e) {
//						MarvelsLogUtil.getInstance().error(">>>>>>>>>>>loanId:" + loanId + ",百融判断用户白名单接口数据落地失败：" + e);
//						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
//						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
//						localStatus = LocalStatus.IN_DATABASE_FAIL.getCode();
//					}
//				} else {
//					resp.setCode(RespStatus.REQ_ERROR.getCode());
//					resp.setMsg("百融判断用户白名单接口,返回错误码：" + code);
//					localStatus = LocalStatus.CALL_SUCCESS.getCode();
//				}
//			} else {
//				resp.setCode(RespStatus.REQ_ERROR.getCode());
//				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
//			}
//		}
//		saveDataQueryLogNew(serialNum, loanId, "", whetherTheUserIsWhiteList.getSwiftNumber(), sTime,
//				ThirdMethodConstants.BR0054, code, localStatus, "edc_br_data_query_log", "");
//		resp.setData(whetherTheUserIsWhiteList);
		return resp;

	}

	// 百融白名单
	public ApiResponse internalWhiteListDeal(Map<String, String> map) {
		ApiResponse<XssPackAllInterfaceInfo> resp = new ApiResponse<XssPackAllInterfaceInfo>();
		/*
		 * 如果接口停用，直接返回（视具体情况，有的返回停用，有的返回相关值） ADD BY TUXU 2018-05-31
		 */
		if (PropertiesUtils.isTurnOffForSwitch("switch.br0053")) {
			// RespStatus.DISABLE只有接口停用时才使用定义的这个参数，其它情况按原本的来
			resp.setCode(RespStatus.DISABLE.getCode());
			resp.setMsg(RespStatus.DISABLE.getMsg());
			return resp;
		}
		JSONObject multipleJson = new JSONObject();
		Date sTime = new Date();
		String meal = "scorepettycashv1,ApplyLoanStr,InfoRelation";
		String loanId = map.get("loanId");
		String channel = map.get("channel");
		String serialNum = SerialNumCreater.creater("BR", loanId);
		;
		ThirdProperties thirdProperties = ThirdPropertiesInitUtil.getThirdProperties();
		multipleJson.put("meal", meal);
		multipleJson.put("id", map.get("idNumber"));
		JSONArray array = new JSONArray();
		array.add(map.get("mobile"));
		multipleJson.put("cell", array.toString());
		multipleJson.put("name", map.get("name"));
		multipleJson.put("bank_id", map.get("bankId"));
		MarvelsLogUtil.getInstance().info("==============loanId:" + loanId + ",百融白名单接口请求参数:" + multipleJson.toString());
		XssPackAllInterfaceInfo xssPackAllInterfaceInfo = new XssPackAllInterfaceInfo();
		String brMerchantName = thirdProperties.getBr_oneCreditCard_merchantName();
		String brMerchantPwd = thirdProperties.getBr_oneCreditCard_merchantPwd();
		String brApiCode = thirdProperties.getBr_oneCreditCard_apiCode();
		String brLoginUrl = thirdProperties.getBr_oneCreditCard_loginRequestUrl();
		String brRequestUrl = thirdProperties.getBr_oneCreditCard_packetRequestUrl();
		String tokenId = platLogin(brMerchantName, brMerchantPwd, brApiCode, brLoginUrl);
		String result = "";
		String swift_number = "";
		String code = "";
		Date responseDate = null;
		String status = LocalStatus.REQUEST_FAIL.getCode();
		String method = ThirdMethodConstants.BR0053;
		if (StringUtils.isEmpty(tokenId)) {
			resp.setCode(RespStatus.REQ_ERROR.getCode());
			resp.setMsg(RespStatus.REQ_ERROR.getMsg());
		} else {
			try {
				result = BaiRongUtil.urlConnectPost(brRequestUrl,
						"tokenid=" + tokenId + "&apiCode=" + brApiCode + "&jsonData="
								+ URLEncoder.encode(multipleJson.toString(), "utf-8") + "&checkCode="
								+ BaiRongUtil.getCheckData(multipleJson.toString(), brApiCode, tokenId));

			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>loanId:" + loanId + ",百融白名单接口请求异常:", e);
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
			responseDate = new Date();
			if (StringUtils.isNotEmpty(result)) {
				MarvelsLogUtil.getInstance().info(">>>>>>>>>>>loanId:" + loanId + ",百融白名单接口返回信息:" + result);
				JSONObject resultJson = new JSONObject();
				resultJson = JSONObject.fromObject(result);
				code = resultJson.get("code").toString();
				if (code.equals("00") || code.equals("100002")) {
					if (code.equals("00")) {
						status = LocalStatus.SUCCESS_WITH_DATA.getCode();
					} else {
						status = LocalStatus.SUCCESS_WITHOUT_DATA.getCode();
					}
					xssPackAllInterfaceInfo = JSON.parseObject(result, XssPackAllInterfaceInfo.class);
					resp.setCode(RespStatus.SUCCESS.getCode());
					resp.setMsg(RespStatus.SUCCESS.getMsg());
					resp.setData(xssPackAllInterfaceInfo);
					Score score = xssPackAllInterfaceInfo.getScoreData();
					MultipleApplications multipleApplications = xssPackAllInterfaceInfo.getMultipleApplicationsData();
					ApplicationInfoAssociate applicationInfoAssociate = xssPackAllInterfaceInfo
							.getApplicationInfoAssociate();
					try {
						// 百融客群评分
						if (meal.contains("scorepettycashv1")) {
							dGBaiRongService.scoreReport(score, serialNum, loanId);
						}
						// 多次申请核查V2
						if (meal.contains("ApplyLoanStr")) {
							dGBaiRongService.multipleApplicationsReport(multipleApplications, serialNum, loanId);
						}
						// 申请信息关联
						if (meal.contains("InfoRelation")) {
							dGBaiRongService.applicationInfoAssociate(applicationInfoAssociate, serialNum, loanId);
						}
						swift_number = xssPackAllInterfaceInfo.getSwift_number();

					} catch (Exception e) {
						MarvelsLogUtil.getInstance().error("loanId:" + loanId + ",百融白名单接口数据落地失败：", e);
						resp.setCode(RespStatus.DATABASE_ERROR.getCode());
						resp.setMsg(RespStatus.DATABASE_ERROR.getMsg());
						status = LocalStatus.IN_DATABASE_FAIL.getCode();
					}
				} else {
					resp.setCode(RespStatus.REQ_ERROR.getCode());
					resp.setMsg("百融白名单接口,返回错误码：" + code);
					status = LocalStatus.CALL_SUCCESS.getCode();
				}
			} else {
				resp.setCode(RespStatus.REQ_ERROR.getCode());
				resp.setMsg(RespStatus.REQ_ERROR.getMsg());
			}
		}
		saveDataQueryLogNew(serialNum, loanId, "", xssPackAllInterfaceInfo.getSwift_number(), sTime,
				ThirdMethodConstants.BR0053, code, status, "edc_br_data_query_log", "");
		return resp;
	}

	// 百融白名单
	@Override
	public ApiResponse internalWhiteList(Map<String, String> hashMap) {
		MarvelsLogUtil.getInstance().info(">>>>>>>>>>百融白名单入口:" + JSONObject.fromObject(hashMap));
		ApiResponse apiResponse = new ApiResponse();
//		String interfaceCode = ThirdMethodConstants.BR0053;
//		String loanId = hashMap.get("loanId");
//		String productType = "";// 产品id
//		String custIdCard = "";
//		String mobile = hashMap.get("mobile");
//		AcLoanApplyInfo queryLoanBasicInfo = loanInfoIDragonService.queryLoanBasicInfo(loanId);
//		if (queryLoanBasicInfo != null) {
//			productType = queryLoanBasicInfo.getProductType() + "";// 产品id
//			custIdCard = queryLoanBasicInfo.getCustIdCard();
//		}
//		Map<String, Object> map = new HashMap<String, Object>();
//		map.put("productType", productType);
//		map.put("interfaceCode", interfaceCode);
//		hashMap.put("idNumber", custIdCard);
//		// 先查询接口的有效期设置 如果未设置则走以前老的接口 如果设置了则判断数据存在与否及数据是否过有效期
//		EdcProductInterfaceEffecttimeConfigDto edcProductInterfaceEffecttimeConfigDto = edcProductInterfaceEffecttimeConfigMapper
//				.selectEdcProInterfaceTimeConfigSig(map);
//		if (edcProductInterfaceEffecttimeConfigDto == null
//				|| (edcProductInterfaceEffecttimeConfigDto != null && edcProductInterfaceEffecttimeConfigDto.getIsUser()
//						&& edcProductInterfaceEffecttimeConfigDto.getValidityDate().equals("0"))) {
//			return internalWhiteListDeal(hashMap);
//		} else if (edcProductInterfaceEffecttimeConfigDto != null
//				&& !edcProductInterfaceEffecttimeConfigDto.getIsUser()) {
//			apiResponse.setCode(RespStatus.SUCCESS.getCode());
//			apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
//			return apiResponse;
//		} else {
//			// 判断数据是否存在
//			Map<String, Object> conditionMap = new HashMap<String, Object>();
//			conditionMap.put("interfaceCode", interfaceCode);
//			conditionMap.put("custIdCard", custIdCard);
//			conditionMap.put("mobile", mobile);
//			conditionMap.put("validityEndDate", edcProductInterfaceEffecttimeConfigDto.getValidityDate());
//			EdcDataCallOperationRecordsDto edcDataCallOperationRecordsDto = edcDataCallOperationRecordsMapper
//					.selectEdcDataCallOperationRecordSig(conditionMap);
//			if (edcDataCallOperationRecordsDto == null) {// 数据不存在 (为第一次调用
//															// 或数据已过有效期)
//				// 调用以前接口
//				apiResponse = internalWhiteListDeal(hashMap);
//
//				// 插入第三方数据调用记录
//				if (apiResponse.getCode() == RespStatus.SUCCESS.getCode()
//						|| apiResponse.getCode() == RespStatus.DATABASE_ERROR.getCode()) {
//					EdcDataCallOperationRecordsDto edcDataCallOperationRecords = new EdcDataCallOperationRecordsDto();
//					edcDataCallOperationRecords.setCustIdCard(custIdCard);
//					edcDataCallOperationRecords.setInterfaceCode(interfaceCode);
//					edcDataCallOperationRecords.setLoanId(loanId);
//					edcDataCallOperationRecords.setMobile(mobile);
//					edcDataCallOperationRecords.setProductType(productType);
//					edcDataCallOperationRecords.setValidityEndDate(SystemUtil.getAddDay(new Date(),
//							Integer.parseInt(edcProductInterfaceEffecttimeConfigDto.getValidityDate())));
//					saveEdcDataCallOperationRecords(edcDataCallOperationRecords);
//				}
//
//			} else {
//				apiResponse.setCode(RespStatus.SUCCESS.getCode());
//				apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
//			}
//		}
		return apiResponse;

	}

	@Override
	public ApiResponse whetherTheUserIsWhiteList(Map<String, String> hashMap) {
		MarvelsLogUtil.getInstance().info(">>>>>>>>>>判断百融白名单入口:" + JSONObject.fromObject(hashMap));
		/*String interfaceCode = ThirdMethodConstants.BR0054;
		String loanId = hashMap.get("loanId");
		String productType = "";// 产品id
		String custIdCard = "";
		String mobile = hashMap.get("mobile");
		WhetherTheUserIsWhiteList whetherTheUserIsWhiteList = new WhetherTheUserIsWhiteList();
		// 先判断是否是本地白名单 是本地白名单便直接返回
		ApiResponse apiResponse = new ApiResponse();
		try {
			Map<String, Object> whiteMap = new HashMap<>();
			whiteMap.put("idCard", hashMap.get("idNumber"));// 身份证
			try {
				boolean queryDecisionWhiteInfo = decisionWhiteListService.queryDecisionWhiteInfo(whiteMap);
				if (queryDecisionWhiteInfo) {
					whetherTheUserIsWhiteList.setWhiteList(true);
					apiResponse.setCode(RespStatus.SUCCESS.getCode());
					apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
					apiResponse.setData(whetherTheUserIsWhiteList);
					return apiResponse;
				}
			} catch (Exception e) {
				MarvelsLogUtil.getInstance().error(">>>>>>>>>>>>>loanId:" + loanId + ",查询用户是否本地白名单异常:" + e);
			}
			AcLoanApplyInfo queryLoanBasicInfo = loanInfoIDragonService.queryLoanBasicInfo(loanId);
			if (queryLoanBasicInfo != null) {
				productType = queryLoanBasicInfo.getProductType() + "";// 产品id
				custIdCard = queryLoanBasicInfo.getCustIdCard();
			}
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("productType", productType);
			map.put("interfaceCode", interfaceCode);
			// 先查询接口的有效期设置 如果未设置则走以前老的接口 如果设置了则判断数据存在与否及数据是否过有效期
			EdcProductInterfaceEffecttimeConfigDto edcProductInterfaceEffecttimeConfigDto = edcProductInterfaceEffecttimeConfigMapper
					.selectEdcProInterfaceTimeConfigSig(map);
			if (edcProductInterfaceEffecttimeConfigDto == null || (edcProductInterfaceEffecttimeConfigDto != null
					&& edcProductInterfaceEffecttimeConfigDto.getIsUser()
					&& edcProductInterfaceEffecttimeConfigDto.getValidityDate().equals("0"))) {
				apiResponse = whetherTheUserIsWhiteListDeal(hashMap);
				return apiResponse;
			} else if (edcProductInterfaceEffecttimeConfigDto != null
					&& !edcProductInterfaceEffecttimeConfigDto.getIsUser()) {
				apiResponse.setCode(RespStatus.SUCCESS.getCode());
				apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
				return apiResponse;
			} else {
				// 判断数据是否存在
				Map<String, Object> conditionMap = new HashMap<String, Object>();
				conditionMap.put("interfaceCode", interfaceCode);
				conditionMap.put("custIdCard", custIdCard);
				conditionMap.put("mobile", mobile);
				conditionMap.put("validityEndDate", edcProductInterfaceEffecttimeConfigDto.getValidityDate());
				EdcDataCallOperationRecordsDto edcDataCallOperationRecordsDto = edcDataCallOperationRecordsMapper
						.selectEdcDataCallOperationRecordSig(conditionMap);
				if (edcDataCallOperationRecordsDto == null) {// 数据不存在 (为第一次调用
																// 或数据已过有效期)
					// 调用以前接口
					apiResponse = whetherTheUserIsWhiteListDeal(hashMap);

					// 插入第三方数据调用记录
					if (apiResponse.getCode() == RespStatus.SUCCESS.getCode()
							|| apiResponse.getCode() == RespStatus.DATABASE_ERROR.getCode()) {
						EdcDataCallOperationRecordsDto edcDataCallOperationRecords = new EdcDataCallOperationRecordsDto();
						edcDataCallOperationRecords.setCustIdCard(custIdCard);
						edcDataCallOperationRecords.setInterfaceCode(interfaceCode);
						edcDataCallOperationRecords.setLoanId(loanId);
						edcDataCallOperationRecords.setMobile(mobile);
						edcDataCallOperationRecords.setProductType(productType);
						edcDataCallOperationRecords.setValidityEndDate(SystemUtil.getAddDay(new Date(),
								Integer.parseInt(edcProductInterfaceEffecttimeConfigDto.getValidityDate())));
						saveEdcDataCallOperationRecords(edcDataCallOperationRecords);
					}

				} else {
					apiResponse.setCode(RespStatus.SUCCESS.getCode());
					apiResponse.setMsg(RespStatus.SUCCESS.getMsg());
					whetherTheUserIsWhiteList.setWhiteList(false);
					apiResponse.setData(whetherTheUserIsWhiteList);
				}
			}
			return apiResponse;
		} finally {
			// 如果是百融白名单，打个标识
			Object data = apiResponse.getData();
			if (data != null) {
				WhetherTheUserIsWhiteList isWhiteList = (WhetherTheUserIsWhiteList) data;
				if (isWhiteList != null && isWhiteList.isWhiteList()) {
					// 不记录不是的
					Integer count = acLoanApplyInfoExtDragonService.queryExtInfoCountByLoanId(loanId);
					Map<String, Object> columnValue = new HashMap<String, Object>();
					columnValue.put("field2", "0");
					if (count > 0) {
						// 存在记录就修改
						acLoanApplyInfoExtDragonService.updateExtInfoByLoanId(columnValue, loanId);
					} else {
						// 不存在新增
						columnValue.put("loan_id", loanId);
						acLoanApplyInfoExtDragonService.insertExtInfo(columnValue);
					}
				}
			}
		}*/
		return null;
	}

}
